from PIL import Image
import os

# 定义路径
black_dir = '/root/code/fe-ma-sr/test/black'
white_dir = '/root/code/fe-ma-sr/test/white'

# 获取black目录下的所有图片文件
filenames = os.listdir(black_dir)

print(f'Found {len(filenames)} images in black directory')

# 为每张图片创建相同尺寸的全白图片
for filename in filenames:
    # 构建完整的文件路径
    black_path = os.path.join(black_dir, filename)
    
    # 打开图片并获取尺寸
    with Image.open(black_path) as img:
        width, height = img.size
        
        # 创建相同尺寸的全白图片
        white_img = Image.new('RGB', (width, height), (255, 255, 255))
        
        # 保存到white目录
        white_path = os.path.join(white_dir, filename)
        white_img.save(white_path)
        
        print(f'Created white image: {filename} ({width}x{height})')

print('All white images created successfully!')